import { constantRoutes } from '@/router'

const state = {
  routes: constantRoutes,
  addRoutes: [],
  roles: ['admin'] // 默认角色
}

const mutations = {
  SET_ROUTES: (state, routes) => {
    state.addRoutes = routes
    state.routes = constantRoutes.concat(routes)
  },
  SET_ROLES: (state, roles) => {
    state.roles = roles
  }
}

const actions = {
  setRoles({ commit }, roles) {
    commit('SET_ROLES', roles)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
} 